init('ServiceRegistry');
(function(){
	var remote   = require('./Remoting.js').create();
	var services = {};
	
	exports.set = function(name, service){
		services[name] = service;
	};
	exports.get = function(name, callback){
		var service = services[name]; 
		if(service){
			callback(service);
			return service;
		}
		var onSuccess = function(service){
			console.log(service);
			callback(service);
		}
		var onFail = function(err){
			callback();
		}
		service = remote.createRemoteService(name, onSuccess, onFail);
		services[name] = service;
		return service;
	}
})();